package io.renren.modules.sys.controller;

import java.util.Arrays;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.renren.common.vo.RV;
import io.renren.modules.sys.entity.Subsys;
import io.renren.modules.sys.service.SubsysService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;



/**
 * 子系统
 *
 * @author jingtang
 * @email sunlightcs@gmail.com
 * @date 2018-06-28 08:41:11
 */
@RestController
@RequestMapping("sys/subsys")
@Api("子系统")
public class SubsysController extends AbstractController{
    @Autowired
    private SubsysService subsysService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("sys:subsys:list")
    public RV list(@RequestParam Map<String, Object> params){
       

        return RV.ok();
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{sysId}")
    @RequiresPermissions("sys:subsys:info")
    public RV info(@PathVariable("sysId") String sysId){
			Subsys subsys = subsysService.selectById(sysId);

        return RV.ok(subsys);
    }

    /**
     * 保存
     */
    @RequestMapping("/savesubsys")
//    @RequiresPermissions("sys:subsys:save")
    @ApiOperation("保存或者更新")
    public RV saveSubsys(@RequestBody Subsys subsys){
    	
        return RV.ok(subsysService.saveSubSys(subsys));
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("sys:subsys:update")
    public RV update(@RequestBody Subsys subsys){
			subsysService.updateById(subsys);

        return RV.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("sys:subsys:delete")
    public RV delete(@RequestBody String[] sysIds){
			subsysService.deleteBatchIds(Arrays.asList(sysIds));

        return RV.ok();
    }

}
